<template>
  <view class="container">
    <view class="user_header">
      <!-- 未登录状态 -->
      <view class="goToLogin" @tap="goToPage('/pages/login/index')" v-if="!userInfo">去登录</view>
      <!-- 已登录状态 -->
      <view class="logo" v-else>
        <image class="icon" :src="userInfo.avatarUrl" />
        <view class="name">{{userInfo.nickName}}</view>
      </view>
      <image v-if="userInfo" :src="userInfo.avatarUrl" class="bg" />
    </view>
    <!-- 订单导航 -->
    <view class="order_nav">
      <view class="nav" @tap="goToPage('/pages/order/index?index=1')">
        <view class="iconfont icon-icon-test"></view>
        <view class="name">待付款</view>
      </view>
      <view class="nav" @tap="goToPage('/pages/order/index?index=2')">
        <view class="iconfont icon-daishouhuo"></view>
        <view class="name">待收货</view>
      </view>
      <view class="nav" @tap="goToPage('/pages/order/index')">
        <view class="iconfont icon-tuihuo"></view>
        <view class="name">退货/退款</view>
      </view>
      <view class="nav" @tap="goToPage('/pages/order/index?index=0')">
        <view class="iconfont icon-quanbudingdan01"></view>
        <view class="name">全部订单</view>
      </view>
    </view>
    <!-- 应用信息 -->
    <view class="app_info">
      <view class="info" @tap="call">
        <view class="iconfont icon-kefu"></view>
        <view class="name">联系客服</view>
        <view class="value">{{phoneNumber}}</view>
      </view>
      <view class="info" @tap="goToPage('/pages/feedback/index')">
        <view class="iconfont icon-fankuitianbao"></view>
        <view class="name">意见反馈</view>
        <view class="value"></view>
      </view>
      <view class="info">
        <view class="iconfont icon-banben"></view>
        <view class="name">当前版本</view>
        <view class="value">v4.1.1</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      userInfo: {}, // 用户信息
      phoneNumber:"17878-53-7074"
    };
  },
  onLoad() {
    console.log(Boolean(this.userInfo));
  },
  onShow() {
    this.userInfo = uni.getStorageSync("userInfo");
  },
  methods: {
    call() {
      // 拨打电话
      uni.makePhoneCall({
        phoneNumber: this.phoneNumber
      });
    },
    goToPage(url) {
      uni.navigateTo({
        url
      });
    }
  }
};
</script>

<style lang="less">
.container {
  background-color: #fafafa;
  .user_header {
    height: 329rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    .bg {
      filter: blur(20rpx);
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      width: 100%;
      height: 100%;
    }
    .logo {
      display: flex;
      flex-direction: column;
      align-items: center;
      z-index: 1;
      .icon {
        width: 172rpx;
        height: 172rpx;
        border-radius: 100%;
      }
      .name {
        color: #fff;
        font-size: 32rpx;
        font-weight: bold;
        margin-top: 16rpx;
      }
    }
    .goToLogin {
      display: flex;
      justify-content: center;
      align-items: center;
      color: #fff;
      font-size: 36rpx;
      background-color: #07c160;
      border-radius: 8rpx;
      width: 352rpx;
      height: 88rpx;
    }
  }
  .order_nav {
    display: flex;
    margin: 0 12rpx;
    border-radius: 8rpx;
    background-color: #fff;
    justify-content: space-around;
    .nav {
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 14rpx 0;
      .iconfont {
        font-size: 60rpx;
      }
      .name {
        font-size: 26rpx;
      }
    }
  }
  .app_info {
    background-color: #fff;
    margin: 20rpx 12rpx;
    font-size: 26rpx;
    color: #434343;
    .iconfont {
      font-size: 45rpx;
    }
    .info {
      display: flex;
      justify-content: space-between;
      height: 101rpx;
      align-items: center;
      padding: 0 40rpx;
      border-bottom: 1px solid #c8c8c8;
      .name {
        margin-left: 28rpx;
      }
      .value {
        flex: 1;
        text-align: right;
      }
    }
  }
}
</style>	